<?php

namespace App\Models;

use Database\Factories\ConnectionsFactory;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ConnectionsTypesModel extends Model
{
    use HasFactory;

    protected $table = 'connections_types';

    public $timestamps = false;

    protected $primaryKey = 'id';

    public function servers()
    {
        return $this->belongsToMany(ServerModel::class,
            'servers_connections',
            'connection',
            'server');
    }

    public function sessions()
    {
        return $this->hasMany(CommandsModel::class, 'connection_id', 'id');
    }

    protected static function newFactory(): Factory
    {
        return ConnectionsFactory::new();
    }
}
